import request from '@/utils/request'

//管理员首页
export const adminHomeService=()=>{
    return request.get('/management/statistics')
}

//注册
export const userRegisterService=({userName,password,email,verification})=>{
    return request.post('/user/register',{
        userName,
        password,
        email,
        verification,
    })
}

//密码登录
export const passwordLoginService=(email,password)=>{
    return request.post('/user/login/password',{
        
        password,
        email,
       
    })
}

//验证码登录
export const verificationLoginService=(email,verification)=>{
    return request.post('/user/login/verification',{
        verification,
        email,
       
    })
}


//忘记密码
export const forgetPasswordService=(email,verification,newPassword)=>{
    return request.put('/user/login/forget',{
        
        verification,
        email,
        newPassword,
       
    })
}

//获取验证码
export const sendVerificationCodeService=(email)=>{
    return request.post('/verification',{email})
}


//获取用户基本信息
export const getUserInformationService=(userId)=>{
    return request.get('/user/select/id',{
        params:{
            userId
        }
    })
}


//用户修改基本信息
export const updataBaseInformationService=(Information)=>{
    return request.put('/user/update/base',Information)
}

//用户修改头像
export const updataAvatarService=(avatarFile)=>{
    return request.put('/user/update/avatar',{
        params:{
            avatarFile
        }
    })
}

//修改密码
export const updataPasswordService=(oldPassword,newPassword)=>{
    return request.put('/user/update/password',{
        oldPassword,
        newPassword
    })
}

// //更改邮箱
export const updataEmailService=(newEmail,verification)=>{
    return request.put("/user/update/email",{
        newEmail,  
        verification
    })
}


// // 注销账号
export const cancelAccountService=(verification)=>{
    return request.post('/user/delete',{
    
            verification
        
    })
}

//管理员删除账号
export const deleteUserService=(userId)=>{
    return request.delete('/management/delete/user',{
        params:{
            userId
        }
    })
}

// // 多条件查找用户
export const finduserService=(pageNum,pageSize,userId,userName,email)=>{
    return request.post('/management/select/users',{
        userId,
        userName,
        email
    },
    {
        params:{
            pageNum,
            pageSize
        }   
    })
}

//JSON-SERVER

// export const userLoginService=(email,password)=>{
//     return request.get('/users',{
//         params:{
//         'email': email,
//         'password': password
//         }
//       })
// }
//返回个人信息
// export const getUserInformationService=(token)=>{
//     return request.get(`/users/${token}`)
// }

// //修改个人信息
// export const editUserInformationService=({id,userName,sex,autograph})=>{
//     return request.patch(`/users/${id}`, {
//         userName,
//         sex,
//         autograph
//     }) 
// }

// //用户注销
// export const LogoutUserService=(token)=>{
//     return request.delete(`/users/${token}`)
// }

// //修改密码
// export const updataPasswordService=(token,newPassword)=>{
//     return request.patch(`/users/${token}`,{
//         password: newPassword
//     })
// }

// //更改邮箱
// export const updataEmailService=(token,newEmail)=>{
//     return request.patch(`/users/${token}`,{
//         email: newEmail   
//     })
// }

// // 注销账号
// export const cancelAccountService=(token)=>{
//     return request.patch(`/users/${token}`,{
           
//     })
// }

// //删除用户
// export const deleteUserService=(userId)=>{
//     return request.delete("/management/user/delete",userId)
// }

